﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Last03.AGerenzhongxin
{
    /// <summary>
    /// xiugaimima.xaml 的交互逻辑
    /// </summary>
    public partial class xiugaimima : Page
    {
        public xiugaimima()
        {
            InitializeComponent();
        }

        HotelEntities context = new HotelEntities();

        private void txtpass_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            this.txtpass.Text = "";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var q = context.Database.SqlQuery<LoginInfo>("select * from LoginInfo");
            this.dataGrid.ItemsSource = q.ToList();
        }

        private void txtsf_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
        {
            this.txtsf.Text = "";
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string ggsql = "update LoginInfo set Password={0} where Bno={1}";
            int j = context.Database.ExecuteSqlCommand(ggsql,txtpass.Text,txtsf.Text);
            if (j < 0)
            {
                MessageBox.Show("请重新输入相关信息！");
            }
            var q = context.Database.SqlQuery<LoginInfo>("select * from LoginInfo");
            this.dataGrid.ItemsSource = q.ToList();
        }
    }
}
